<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数据分析 - SaaS Dashboard</title>
    <!-- 引入Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- 引入Font Awesome -->
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <!-- 引入Chart.js -->
    <script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
    <!-- 自定义CSS -->
    <style>
        /* 全局样式 */
        :root {
            --primary-color: #4f46e5;
            --secondary-color: #64748b;
            --success-color: #10b981;
            --warning-color: #f59e0b;
            --danger-color: #ef4444;
            --light-bg: #f8fafc;
            --dark-bg: #0f172a;
            --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
            --transition: all 0.3s ease;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: var(--light-bg);
            color: #334155;
            overflow-x: hidden;
        }

        /* 加载动画 */
        .loader {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: var(--primary-color);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 9999;
            transition: opacity 0.5s ease, visibility 0.5s ease;
        }

        .loader.hidden {
            opacity: 0;
            visibility: hidden;
        }

        .loader::after {
            content: '';
            width: 50px;
            height: 50px;
            border: 5px solid #fff;
            border-top-color: transparent;
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }

        @keyframes spin {
            to {
                transform: rotate(360deg);
            }
        }

        /* 主容器 */
        .main-container {
            display: flex;
            min-height: 100vh;
        }

        /* 侧边栏 */
        .sidebar {
            width: 280px;
            background-color: #2c3e50;
            box-shadow: var(--card-shadow);
            transition: var(--transition);
            position: fixed;
            height: 100vh;
            overflow-y: auto;
            z-index: 100;
            color: white;
        }

        .sidebar.collapsed {
            width: 80px;
        }

        .sidebar.collapsed .logo-text {
            display: none;
        }

        .sidebar.collapsed .sidebar-nav a {
            justify-content: center;
            padding: 12px 0;
            font-size: 0;
        }

        .sidebar.collapsed .sidebar-nav a i {
            margin-right: 0;
            font-size: 16px;
        }

        .sidebar.collapsed .sidebar-header {
            justify-content: center;
        }

        

        /* 侧边栏头部 */
        .sidebar-header {
            padding: 1.5rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom: 1px solid #34495e;
        }

        .logo {
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }

        .logo-icon {
            width: 40px;
            height: 40px;
            background: linear-gradient(135deg, var(--primary-color), #818cf8);
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #fff;
            font-size: 1.5rem;
            font-weight: bold;
        }

        .logo-text {
            font-size: 1.25rem;
            font-weight: 700;
            color: white;
        }

        .sidebar-toggle {
            background: none;
            border: none;
            font-size: 1.25rem;
            color: white;
            cursor: pointer;
            padding: 0.5rem;
            border-radius: 4px;
            transition: var(--transition);
        }

        .sidebar-toggle:hover {
            background-color: #34495e;
            color: white;
        }

        /* 侧边栏导航 */
        .sidebar-nav {
            padding: 1rem 0;
        }

        .nav-item {
            margin-bottom: 0.25rem;
        }

        .nav-link {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.75rem 1.5rem;
            color: white;
            text-decoration: none;
            transition: var(--transition);
            border-left: 3px solid transparent;
        }

        .nav-link:hover {
            background-color: #34495e;
            border-left-color: #3498db;
        }

        .nav-link.active {
            background-color: #34495e;
            color: white;
            border-left-color: #3498db;
            font-weight: 500;
        }

        .nav-icon {
            font-size: 1.125rem;
            width: 20px;
            text-align: center;
        }

        .nav-text {
            font-weight: 500;
        }

        /* 主内容区域 */
        .main-content {
            flex: 1;
            margin-left: 280px;
            transition: var(--transition);
        }

        .main-content.expanded {
            margin-left: 80px;
        }

        /* 顶部导航栏 */
        .top-nav {
            background-color: #fff;
            box-shadow: var(--card-shadow);
            padding: 1rem 2rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
            position: sticky;
            top: 0;
            z-index: 99;
        }

        .nav-left {
            display: flex;
            align-items: center;
            gap: 1rem;
        }

        /* 搜索框 */
        .search-box {
            position: relative;
        }

        .search-box input {
            width: 300px;
            padding: 0.75rem 1rem 0.75rem 2.5rem;
            border: 1px solid #e2e8f0;
            border-radius: 8px;
            font-size: 0.875rem;
            transition: var(--transition);
        }

        .search-box input:focus {
            outline: none;
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
        }

        .search-box .fa-search {
            position: absolute;
            left: 1rem;
            top: 50%;
            transform: translateY(-50%);
            color: var(--secondary-color);
        }

        /* 导航右侧 */
        .nav-right {
            display: flex;
            align-items: center;
            gap: 1rem;
        }

        /* 通知图标 */
        .notification-icon {
            position: relative;
            font-size: 1.25rem;
            color: var(--secondary-color);
            cursor: pointer;
            transition: var(--transition);
        }

        .notification-icon:hover {
            color: var(--primary-color);
        }

        .notification-badge {
            position: absolute;
            top: -5px;
            right: -5px;
            background-color: var(--danger-color);
            color: #fff;
            font-size: 0.75rem;
            padding: 0.125rem 0.375rem;
            border-radius: 50%;
            min-width: 18px;
            text-align: center;
        }

        /* 用户信息 */
        .user-info {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            cursor: pointer;
            padding: 0.5rem;
            border-radius: 8px;
            transition: var(--transition);
        }

        .user-info:hover {
            background-color: #f1f5f9;
        }

        .user-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: linear-gradient(135deg, var(--primary-color), #818cf8);
            display: flex;
            align-items: center;
            justify-content: center;
            color: #fff;
            font-weight: 600;
        }

        .user-details {
            display: flex;
            flex-direction: column;
        }

        .user-name {
            font-size: 0.875rem;
            font-weight: 600;
            color: var(--dark-bg);
        }

        .user-role {
            font-size: 0.75rem;
            color: var(--secondary-color);
        }

        /* 内容区域 */
        .content {
            padding: 2rem;
        }

        /* 页面标题 */
        .page-title {
            margin-bottom: 2rem;
        }

        .page-title h1 {
            font-size: 1.875rem;
            font-weight: 700;
            color: var(--dark-bg);
            margin: 0;
        }

        /* 筛选区域 */
        .filter-section {
            background-color: #fff;
            padding: 1.5rem;
            border-radius: 12px;
            box-shadow: var(--card-shadow);
            margin-bottom: 1.5rem;
            border: 1px solid #e2e8f0;
        }

        .filter-row {
            display: flex;
            gap: 1.5rem;
            align-items: center;
            flex-wrap: wrap;
        }

        .filter-group {
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }

        .filter-group label {
            font-weight: 500;
            color: var(--secondary-color);
            font-size: 0.875rem;
        }

        .filter-group select,
        .filter-group input {
            padding: 0.5rem 1rem;
            border: 1px solid #e2e8f0;
            border-radius: 6px;
            font-size: 0.875rem;
            transition: var(--transition);
        }

        .filter-group select:focus,
        .filter-group input:focus {
            outline: none;
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
        }

        /* 数据卡片 */
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 1.5rem;
            margin-bottom: 2rem;
        }

        .stat-card {
            background-color: #fff;
            padding: 1.5rem;
            border-radius: 12px;
            box-shadow: var(--card-shadow);
            transition: var(--transition);
            border: 1px solid #e2e8f0;
        }

        .stat-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }

        .stat-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 1rem;
        }

        .stat-title {
            font-size: 0.875rem;
            font-weight: 500;
            color: var(--secondary-color);
        }

        .stat-icon {
            width: 40px;
            height: 40px;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.125rem;
        }

        .stat-icon.primary {
            background-color: #ede9fe;
            color: var(--primary-color);
        }

        .stat-icon.success {
            background-color: #d1fae5;
            color: var(--success-color);
        }

        .stat-icon.warning {
            background-color: #fef3c7;
            color: var(--warning-color);
        }

        .stat-icon.danger {
            background-color: #fee2e2;
            color: var(--danger-color);
        }

        .stat-value {
            font-size: 2rem;
            font-weight: 700;
            color: var(--dark-bg);
            margin-bottom: 0.5rem;
        }

        .stat-change {
            font-size: 0.875rem;
            font-weight: 500;
            display: flex;
            align-items: center;
            gap: 0.25rem;
        }

        .stat-change.positive {
            color: var(--success-color);
        }

        .stat-change.negative {
            color: var(--danger-color);
        }

        /* 图表容器 */
        .chart-container {
            background-color: #fff;
            padding: 1.5rem;
            border-radius: 12px;
            box-shadow: var(--card-shadow);
            margin-bottom: 1.5rem;
            border: 1px solid #e2e8f0;
        }

        .chart-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1.5rem;
        }

        .chart-title {
            font-size: 1.125rem;
            font-weight: 600;
            color: var(--dark-bg);
            margin: 0;
        }

        .chart-actions {
            display: flex;
            gap: 0.75rem;
        }

        /* 按钮样式 */
        .btn {
            padding: 0.75rem 1.5rem;
            border: none;
            border-radius: 8px;
            font-weight: 500;
            font-size: 0.875rem;
            transition: var(--transition);
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
        }

        .btn-primary {
            background-color: var(--primary-color);
            color: #fff;
        }

        .btn-primary:hover {
            background-color: #4338ca;
            transform: translateY(-1px);
        }

        .btn-secondary {
            background-color: #f1f5f9;
            color: var(--secondary-color);
            border: 1px solid #e2e8f0;
        }

        .btn-secondary:hover {
            background-color: #e2e8f0;
        }

        /* 图表样式 */
        .chart-wrapper {
            position: relative;
            height: 350px;
        }

        /* 图表网格布局 */
        .charts-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
            gap: 1.5rem;
            margin-bottom: 1.5rem;
        }

        /* 全宽图表 */
        .chart-full-width {
            grid-column: 1 / -1;
        }

        /* 响应式设计 */
        @media (max-width: 1200px) {
            .charts-grid {
                grid-template-columns: 1fr;
            }
        }

        @media (max-width: 768px) {
            .sidebar {
                transform: translateX(-100%);
            }

            .sidebar.open {
                transform: translateX(0);
            }

            .main-content {
                margin-left: 0;
            }

            .top-nav {
                padding: 1rem;
            }

            .search-box input {
                width: 200px;
            }

            .content {
                padding: 1rem;
            }

            .filter-row {
                flex-direction: column;
                align-items: stretch;
            }

            .filter-group {
                flex-direction: column;
                align-items: stretch;
            }

            .stats-grid {
                grid-template-columns: 1fr;
            }
        }

        /* 滚动条样式 */
        ::-webkit-scrollbar {
            width: 8px;
        }

        ::-webkit-scrollbar-track {
            background: #f1f5f9;
        }

        ::-webkit-scrollbar-thumb {
            background: #cbd5e1;
            border-radius: 4px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: #94a3b8;
        }
    </style>
</head>
<body>
    <!-- 加载动画 -->
    <div class="loader"></div>

    <div class="main-container">
        <!-- 侧边栏 -->
        <aside class="sidebar" id="sidebar">
            <div class="sidebar-header">
                <div class="logo">
                    <div class="logo-icon">S</div>
                    <span class="logo-text">平台端系统</span>
                </div>
                <button class="sidebar-toggle" id="sidebarToggle">
                <i class="fa fa-angle-left toggle-icon"></i>
            </button>
            </div>
            <nav class="sidebar-nav">
                <a href="index.html" class="nav-link">
                    <i class="fa fa-dashboard nav-icon"></i>
                    <span class="nav-text">仪表盘</span>
                </a>
                <a href="users.html" class="nav-link">
                    <i class="fa fa-users nav-icon"></i>
                    <span class="nav-text">用户管理</span>
                </a>
                <a href="analytics.html" class="nav-link active">
                    <i class="fa fa-bar-chart nav-icon"></i>
                    <span class="nav-text">数据分析</span>
                </a>
                <a href="tenant-settings.html" class="nav-link">
                    <i class="fa fa-building nav-icon"></i>
                    <span class="nav-text">租户设置</span>
                </a>
                <a href="contracts.html" class="nav-link">
                    <i class="fa fa-file-text-o nav-icon"></i>
                    <span class="nav-text">合同管理</span>
                </a>
                <a href="settings.html" class="nav-link">
                    <i class="fa fa-cog nav-icon"></i>
                    <span class="nav-text">系统设置</span>
                </a>
                <a href="notifications.html" class="nav-link">
                    <i class="fa fa-bell nav-icon"></i>
                    <span class="nav-text">通知中心</span>
                </a>
                <a href="reports.html" class="nav-link">
                    <i class="fa fa-file-text nav-icon"></i>
                    <span class="nav-text">报表管理</span>
                </a>
                <a href="orders.html" class="nav-link">
                    <i class="fa fa-shopping-cart nav-icon"></i>
                    <span class="nav-text">订单管理</span>
                </a>
                <a href="help.html" class="nav-link">
                    <i class="fa fa-question-circle nav-icon"></i>
                    <span class="nav-text">帮助中心</span>
                </a>
            </nav>
        </aside>

        <!-- 主内容 -->
        <main class="main-content" id="mainContent">
            <!-- 顶部导航栏 -->
            <nav class="top-nav">
                <div class="nav-left">
                    <button class="sidebar-toggle d-md-none" id="mobileSidebarToggle">
                        <i class="fa fa-bars"></i>
                    </button>
                    <div class="search-box">
                        <i class="fa fa-search"></i>
                        <input type="text" placeholder="搜索...">
                    </div>
                </div>
                <div class="nav-right">
                    <div class="notification-icon">
                        <i class="fa fa-bell"></i>
                        <span class="notification-badge">3</span>
                    </div>
                    <div class="user-info">
                        <div class="user-avatar">JD</div>
                        <div class="user-details">
                            <div class="user-name">John Doe</div>
                            <div class="user-role">管理员</div>
                        </div>
                        <i class="fa fa-chevron-down"></i>
                    </div>
                </div>
            </nav>

            <!-- 内容区域 -->
            <div class="content">
                <!-- 页面标题 -->
                <div class="page-title">
                    <h1>数据分析</h1>
                </div>

                <!-- 筛选区域 -->
                <div class="filter-section">
                    <div class="filter-row">
                        <div class="filter-group">
                            <label for="time-range">时间范围</label>
                            <select id="time-range">
                                <option value="7d">最近7天</option>
                                <option value="30d" selected>最近30天</option>
                                <option value="90d">最近90天</option>
                                <option value="1y">最近1年</option>
                            </select>
                        </div>
                        <div class="filter-group">
                            <label for="data-type">数据类型</label>
                            <select id="data-type">
                                <option value="all" selected>全部数据</option>
                                <option value="users">用户数据</option>
                                <option value="revenue">收入数据</option>
                                <option value="traffic">流量数据</option>
                            </select>
                        </div>
                        <div class="filter-group">
                            <label for="segment">用户细分</label>
                            <select id="segment">
                                <option value="all" selected>全部用户</option>
                                <option value="new">新用户</option>
                                <option value="active">活跃用户</option>
                                <option value="premium">付费用户</option>
                            </select>
                        </div>
                        <div class="filter-group" style="margin-left: auto;">
                            <button class="btn btn-primary">
                                <i class="fa fa-download"></i>
                                导出数据
                            </button>
                            <button class="btn btn-secondary">
                                <i class="fa fa-refresh"></i>
                                刷新数据
                            </button>
                        </div>
                    </div>
                </div>

                <!-- 关键指标卡片 -->
                <div class="stats-grid">
                    <div class="stat-card">
                        <div class="stat-header">
                            <span class="stat-title">总访问量</span>
                            <div class="stat-icon primary">
                                <i class="fa fa-line-chart"></i>
                            </div>
                        </div>
                        <div class="stat-value">125,432</div>
                        <div class="stat-change positive">
                            <i class="fa fa-arrow-up"></i>
                            <span>15.2% 较上月</span>
                        </div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-header">
                            <span class="stat-title">活跃用户</span>
                            <div class="stat-icon success">
                                <i class="fa fa-users"></i>
                            </div>
                        </div>
                        <div class="stat-value">8,765</div>
                        <div class="stat-change positive">
                            <i class="fa fa-arrow-up"></i>
                            <span>8.5% 较上月</span>
                        </div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-header">
                            <span class="stat-title">转化率</span>
                            <div class="stat-icon warning">
                                <i class="fa fa-percent"></i>
                            </div>
                        </div>
                        <div class="stat-value">4.8%</div>
                        <div class="stat-change positive">
                            <i class="fa fa-arrow-up"></i>
                            <span>0.5% 较上月</span>
                        </div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-header">
                            <span class="stat-title">平均会话时长</span>
                            <div class="stat-icon danger">
                                <i class="fa fa-clock-o"></i>
                            </div>
                        </div>
                        <div class="stat-value">3m 45s</div>
                        <div class="stat-change negative">
                            <i class="fa fa-arrow-down"></i>
                            <span>5.2% 较上月</span>
                        </div>
                    </div>
                </div>

                <!-- 图表区域 -->
                <div class="charts-grid">
                    <!-- 收入趋势图 -->
                    <div class="chart-container chart-full-width">
                        <div class="chart-header">
                            <h3 class="chart-title">收入趋势</h3>
                            <div class="chart-actions">
                                <button class="btn btn-secondary btn-sm active">周</button>
                                <button class="btn btn-secondary btn-sm">月</button>
                                <button class="btn btn-secondary btn-sm">年</button>
                            </div>
                        </div>
                        <div class="chart-wrapper">
                            <canvas id="revenueTrendChart"></canvas>
                        </div>
                    </div>

                    <!-- 用户增长图 -->
                    <div class="chart-container">
                        <div class="chart-header">
                            <h3 class="chart-title">用户增长</h3>
                        </div>
                        <div class="chart-wrapper">
                            <canvas id="userGrowthChart"></canvas>
                        </div>
                    </div>

                    <!-- 用户来源分布 -->
                    <div class="chart-container">
                        <div class="chart-header">
                            <h3 class="chart-title">用户来源分布</h3>
                        </div>
                        <div class="chart-wrapper">
                            <canvas id="userSourceChart"></canvas>
                        </div>
                    </div>

                    <!-- 设备分布 -->
                    <div class="chart-container">
                        <div class="chart-header">
                            <h3 class="chart-title">设备分布</h3>
                        </div>
                        <div class="chart-wrapper">
                            <canvas id="deviceDistributionChart"></canvas>
                        </div>
                    </div>

                    <!-- 地域分布 -->
                    <div class="chart-container">
                        <div class="chart-header">
                            <h3 class="chart-title">地域分布</h3>
                        </div>
                        <div class="chart-wrapper">
                            <canvas id="regionDistributionChart"></canvas>
                        </div>
                    </div>
                </div>
            </div>
        </main>
    </div>

    <!-- 引入Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <!-- 自定义JS -->
    <script>
        // 页面加载动画
        window.addEventListener('load', () => {
            const loader = document.querySelector('.loader');
            loader.classList.add('hidden');
        });

        // 侧边栏切换
        const sidebarToggle = document.getElementById('sidebarToggle');
        const sidebar = document.getElementById('sidebar');
        const mainContent = document.getElementById('mainContent');
        const mobileSidebarToggle = document.getElementById('mobileSidebarToggle');

        sidebarToggle.addEventListener('click', () => {
            sidebar.classList.toggle('collapsed');
            mainContent.classList.toggle('expanded');
            // 切换按钮图标
            const toggleIcon = sidebarToggle.querySelector('.toggle-icon');
            if (sidebar.classList.contains('collapsed')) {
                toggleIcon.classList.remove('fa-angle-left');
                toggleIcon.classList.add('fa-angle-right');
            } else {
                toggleIcon.classList.remove('fa-angle-right');
                toggleIcon.classList.add('fa-angle-left');
            }
        });

        mobileSidebarToggle.addEventListener('click', () => {
            sidebar.classList.toggle('open');
        });

        // 点击主内容区域关闭侧边栏（移动端）
        mainContent.addEventListener('click', () => {
            if (sidebar.classList.contains('open')) {
                sidebar.classList.remove('open');
            }
        });

        // 初始化图表
        document.addEventListener('DOMContentLoaded', () => {
            // 收入趋势图
            const revenueCtx = document.getElementById('revenueTrendChart').getContext('2d');
            new Chart(revenueCtx, {
                type: 'line',
                data: {
                    labels: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
                    datasets: [
                        {
                            label: '月度收入',
                            data: [12000, 19000, 15000, 25000, 22000, 30000, 28000, 35000, 32000, 40000, 38000, 45000],
                            borderColor: '#4f46e5',
                            backgroundColor: 'rgba(79, 70, 229, 0.1)',
                            borderWidth: 3,
                            fill: true,
                            tension: 0.4,
                            pointBackgroundColor: '#4f46e5',
                            pointBorderColor: '#fff',
                            pointBorderWidth: 2,
                            pointRadius: 6,
                            pointHoverRadius: 8
                        },
                        {
                            label: '目标收入',
                            data: [15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000, 55000, 60000, 65000, 70000],
                            borderColor: '#94a3b8',
                            borderWidth: 2,
                            fill: false,
                            tension: 0.4,
                            borderDash: [5, 5],
                            pointBackgroundColor: '#94a3b8',
                            pointBorderColor: '#fff',
                            pointBorderWidth: 2,
                            pointRadius: 4,
                            pointHoverRadius: 6
                        }
                    ]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    plugins: {
                        legend: {
                            position: 'top',
                            labels: {
                                usePointStyle: true,
                                padding: 20
                            }
                        },
                        tooltip: {
                            backgroundColor: 'rgba(15, 23, 42, 0.9)',
                            padding: 12,
                            titleFont: {
                                size: 14,
                                weight: '600'
                            },
                            bodyFont: {
                                size: 13
                            },
                            borderColor: '#e2e8f0',
                            borderWidth: 1,
                            callbacks: {
                                label: function(context) {
                                    return `${context.dataset.label}: ¥${context.parsed.y.toLocaleString()}`;
                                }
                            }
                        }
                    },
                    scales: {
                        y: {
                            beginAtZero: true,
                            ticks: {
                                callback: function(value) {
                                    return `¥${value / 1000}k`;
                                }
                            }
                        }
                    },
                    animation: {
                        duration: 1500,
                        easing: 'easeInOutQuart'
                    }
                }
            });

            // 用户增长图
            const userGrowthCtx = document.getElementById('userGrowthChart').getContext('2d');
            new Chart(userGrowthCtx, {
                type: 'bar',
                data: {
                    labels: ['1月', '2月', '3月', '4月', '5月', '6月'],
                    datasets: [
                        {
                            label: '新用户',
                            data: [1200, 1900, 1500, 2500, 2200, 3000],
                            backgroundColor: '#4f46e5',
                            borderRadius: 6
                        },
                        {
                            label: '活跃用户',
                            data: [800, 1200, 1000, 1800, 1600, 2200],
                            backgroundColor: '#10b981',
                            borderRadius: 6
                        }
                    ]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    plugins: {
                        legend: {
                            position: 'top',
                            labels: {
                                usePointStyle: true,
                                padding: 20
                            }
                        }
                    },
                    scales: {
                        y: {
                            beginAtZero: true
                        }
                    },
                    animation: {
                        duration: 1500,
                        easing: 'easeInOutQuart'
                    }
                }
            });

            // 用户来源分布
            const userSourceCtx = document.getElementById('userSourceChart').getContext('2d');
            new Chart(userSourceCtx, {
                type: 'doughnut',
                data: {
                    labels: ['搜索引擎', '社交媒体', '直接访问', ' referral', '邮件营销'],
                    datasets: [
                        {
                            data: [35, 25, 20, 15, 5],
                            backgroundColor: [
                                '#4f46e5',
                                '#8b5cf6',
                                '#3b82f6',
                                '#10b981',
                                '#f59e0b'
                            ],
                            borderWidth: 0,
                            hoverOffset: 10
                        }
                    ]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    plugins: {
                        legend: {
                            position: 'bottom',
                            labels: {
                                padding: 20,
                                usePointStyle: true
                            }
                        },
                        tooltip: {
                            backgroundColor: 'rgba(15, 23, 42, 0.9)',
                            padding: 12,
                            titleFont: {
                                size: 14,
                                weight: '600'
                            },
                            bodyFont: {
                                size: 13
                            },
                            borderColor: '#e2e8f0',
                            borderWidth: 1,
                            callbacks: {
                                label: function(context) {
                                    return `${context.label}: ${context.parsed}%`;
                                }
                            }
                        }
                    },
                    animation: {
                        duration: 1500,
                        easing: 'easeInOutQuart'
                    }
                }
            });

            // 设备分布
            const deviceCtx = document.getElementById('deviceDistributionChart').getContext('2d');
            new Chart(deviceCtx, {
                type: 'pie',
                data: {
                    labels: ['桌面端', '移动端', '平板'],
                    datasets: [
                        {
                            data: [45, 40, 15],
                            backgroundColor: [
                                '#3b82f6',
                                '#4f46e5',
                                '#8b5cf6'
                            ],
                            borderWidth: 0,
                            hoverOffset: 10
                        }
                    ]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    plugins: {
                        legend: {
                            position: 'bottom',
                            labels: {
                                padding: 20,
                                usePointStyle: true
                            }
                        },
                        tooltip: {
                            backgroundColor: 'rgba(15, 23, 42, 0.9)',
                            padding: 12,
                            titleFont: {
                                size: 14,
                                weight: '600'
                            },
                            bodyFont: {
                                size: 13
                            },
                            borderColor: '#e2e8f0',
                            borderWidth: 1,
                            callbacks: {
                                label: function(context) {
                                    return `${context.label}: ${context.parsed}%`;
                                }
                            }
                        }
                    },
                    animation: {
                        duration: 1500,
                        easing: 'easeInOutQuart'
                    }
                }
            });

            // 地域分布
            const regionCtx = document.getElementById('regionDistributionChart').getContext('2d');
            new Chart(regionCtx, {
                type: 'bar',
                data: {
                    labels: ['北京', '上海', '广州', '深圳', '杭州', '成都'],
                    datasets: [
                        {
                            label: '用户数量',
                            data: [12000, 9000, 7500, 8000, 6000, 4500],
                            backgroundColor: '#4f46e5',
                            borderRadius: 6
                        }
                    ]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    indexAxis: 'y',
                    plugins: {
                        legend: {
                            display: false
                        }
                    },
                    scales: {
                        x: {
                            beginAtZero: true
                        }
                    },
                    animation: {
                        duration: 1500,
                        easing: 'easeInOutQuart'
                    }
                }
            });
        });
    </script>
</body>
</html>